package cn.yunhe.servlet;

import cn.yunhe.bean.Travel;
import cn.yunhe.biz.TravelService;
import cn.yunhe.dao.TravelMapper;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/TravelServlet")
public class TravelServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        TravelService travelService = new TravelService();

        List<Travel> travelList = travelService.getAllTravel();


        request.setAttribute("travelList", travelList);


        request.getRequestDispatcher("travelNote.jsp").forward(request, response);

    }
}
